package com.heima.user.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.heima.apis.use.IUseClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.service.ApUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/client/user")
public class UseClientImpl implements IUseClient {
    @Autowired
    private ApUserService apUserService;
    @Override
    @GetMapping("/findById")
    public ResponseResult<ApUser> findById(@RequestParam("useId")Integer useId) {
        //根据id查user
        LambdaQueryWrapper<ApUser> apUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
        apUserLambdaQueryWrapper.eq(ApUser::getId,useId);
        ApUser byId = apUserService.getOne(apUserLambdaQueryWrapper);

        //数据脱敏
        byId.setPassword(null);
        byId.setSalt(null);


        return ResponseResult.okResult(byId);
    }
}
